home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / ftransapiv1.3 / arexx / ftranswordworth.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-30  |  4KB  |  131 lines

  1. /* 
  2.  
  3.  -------------------------------------------
  4.  WordWorth Translator By FTranslator Client
  5.  
  6.  Script by Cristian Robert Gallas
  7.  
  8.  Tested with WordWorth 7
  9.  Usage:                                
  10.  Use in ARexx interface of WordWorth
  11.  $VER: FTransWORDWORTH.rexx v1.0 (25.09.96)
  12.  -------------------------------------------
  13.  
  14.  HISTORY
  15.  ----------------------------------------
  16.  v0.01b [15.08.98] - First public beta version.
  17.  v1.0   [25.09.99] - Modified to FTrans 1.2 API;
  18.  ----------------------------------------
  19.  
  20.  [Steps installation]
  21.  
  22.  > Copy FTransWORDWORTH.rexx to WordWorth:WwRexx/
  23.  > Go to Tools/ARexx Macros...
  24.  > Click ADD and select FTransWORDWORTH.rexx
  25.  > Select Close
  26.  > Select Text
  27.  > Go to Tools/ARexx Macros...
  28.  > Select FTransWORDWORTH.rexx and click PLAY
  29.  > Its open new window with translation... :)
  30.  
  31.  0 - English   to Francais
  32.  1 - English   to Deutsch
  33.  2 - English   to Italiano
  34.  3 - English   to Portugues
  35.  4 - English   to Espanol
  36.  5 - Francais  to English
  37.  6 - Deutsch   to English
  38.  7 - Italiano  to English
  39.  8 - Espanol   to English
  40.  9 - Portugues to English
  41.  
  42. */
  43.  
  44. Options Results
  45.  
  46. tmpfile = 'Ram:FTransTmp.WORDWORTH'
  47. tmpclip = 'Ram:FTransWordWorth.Clip'
  48.  
  49. ARG traduz
  50.  
  51. /* TESTA SE PODE SER USADAS AS LIBS DO AREXX */
  52. if ~show(l, "rexxsupport.library") then
  53.   if ~addlib("rexxsupport.library", 0, -30) then
  54.     exit
  55. if ~show(l, "rexxtricks.library") then
  56.   if ~addlib("rexxtricks.library", 0, -30) then
  57.     exit
  58.  
  59. /* TESTA SE O PROGRAMA JA NAO ESTA COM A PORTA DE TRADUCAO ABERTA */
  60. if exists(tmpfile) then do
  61.   RequestNotify 'FTranslation port is open! Translation in progress, wait...'
  62.   exit
  63. end
  64.  
  65. COPY
  66.  
  67. /* PEGA O CONTEUDO DO CLIPBOARD */
  68. sel = ReadClipboard(0)
  69.  
  70. /* TESTA SE FOI SELECIONADO O TEXTO */
  71. if sel = "" then do
  72.   RequestNotify 'You need select text first...'
  73.   exit
  74. end
  75.  
  76. call open(1, tmpclip, 'W')
  77. call writeln(1, sel)
  78. call close(1)
  79.  
  80. /* COLOCA COMO DEFAULT PORTUGUES TO ENGLISH */
  81. if traduz = "" then do
  82.   Result = ""
  83.   WIZARDREQ TITLE "Freedom Translator Menu 1" LABEL "Select direction of your translation?" BUTTON 1 "Eng->Fra" BUTTON 2 "Eng->Deu" BUTTON 3 "Eng->Ita" BUTTON 4 "Eng->Por" BUTTON 5 "_Others Directions"
  84.   Select
  85.     When Result = -1 then exit
  86.     When Result = 1  then do; traduz = 0; INICIO(); end
  87.     When Result = 2  then do; traduz = 1; INICIO(); end
  88.     When Result = 3  then do; traduz = 2; INICIO(); end
  89.     When Result = 4  then do; traduz = 3; INICIO(); end
  90.     When Result = 5  then do
  91.       Result = ""
  92.       WIZARDREQ TITLE "Freedom Translator Menu 2" LABEL "Select direction of your translation?" BUTTON 1 "Eng->Esp" BUTTON 2 "Fra->Eng" BUTTON 3 "Deu->Eng" BUTTON 4 "Ita->Eng" BUTTON 5 "_Others Directions"
  93.       Select
  94.         When Result = -1 then exit
  95.         When Result = 1  then do; traduz = 4; INICIO(); end
  96.         When Result = 2  then do; traduz = 5; INICIO(); end
  97.         When Result = 3  then do; traduz = 6; INICIO(); end
  98.         When Result = 4  then do; traduz = 7; INICIO(); end
  99.         When Result = 5  then do
  100.           Result = ""
  101.           WIZARDREQ TITLE "Freedom Translator Menu 3" LABEL "Select direction of your translation?" BUTTON 1 "Esp->Eng" BUTTON 2 "Por->Eng"
  102.           Select
  103.             When Result = -1 then exit
  104.             When Result = 1  then do; traduz = 8; INICIO(); end
  105.             When Result = 2  then do; traduz = 9; INICIO(); end
  106.           end
  107.         end
  108.       end
  109.     end
  110.   end /* SELECT MENU 1 */
  111. end
  112.  
  113. INICIO()
  114.  
  115. INICIO:
  116.  
  117. /* EXECUTA O FTRANSLATOR COM OS ARGUMENTOS DA TRADUCAO */
  118. comando = 'C:FTranslator -F "'tmpclip'" -D 'traduz' SILENCE > 'tmpfile
  119. Address Command comando
  120. Address Command 'Delete "'tmpclip'"'
  121.  
  122. NEW PORTNAME 'WORDWORTH.FTRANS'
  123. ADDRESS VALUE RESULT
  124. ADDRESS 'WORDWORTH.FTRANS'
  125. OPEN FILENAME tmpfile
  126.  
  127. Address Command 'Delete "'tmpfile'"'
  128.  
  129. exit
  130.  
  131.